function Stack() {
    this.items = [];

Stack.prototype.push = function(item) {
    this.items.push(item);
}
Stack.prototype.pop=function(){
    return this.items.pop()
}
Stack.prototype.peek=function(  ){
    return this.items[this.items.length-1]
}
Stack.prototype.isEmpty=function(){
return this.items.length==0
}
Stack.prototype.size=function(){
    return this.items.length
}
Stack.prototype.tostring=function(){
    var resultString=""
    for (let i = 0; i < this.items.length; i++) {
        resultString+=this.items[i]+''
        
    }
    return resultString
}
}

// Stack的使用
var s = new Stack();

s.push(1);
s.push(2);
s.push(3);
console.log(s);

s.pop();
console.log(s);

console.log(s.peek());

console.log(s.isEmpty());
console.log(s.size());
